<%@page import="java.util.Date"%>
<%@ page contentType="text/html; charset=UTF-8"%>
<%@ include file="/classes/DBHelper.class.jsp"%>
<%@ include file="/classes/CommonHelper.class.jsp"%>
<%

	String loginId=(String)(session.getAttribute("loginId")==null?"":session.getAttribute("loginId"));
	if(nullOrEmpty(loginId)){
		out.print("<script>alert(\"请登陆后操作！\");</script>");
		return;
	}
	
	String title = getParameter(request,"title");
	String content = getParameter(request,"content");
	String status = getParameter(request,"status");
	String dept_code = getParameter(request,"dept_code");
	String jzsj = getParameter(request,"jzsj");
	String kssj = getParameter(request,"kssj");
	//站点
	String website_code = getParameter(request,"website_code");
	if(nullOrEmpty(title) || nullOrEmpty(content) || nullOrEmpty(status) || nullOrEmpty(dept_code) || nullOrEmpty(website_code)){
		%>
		<script type="text/javascript">
			alert("请检查您提交的数据是否完整！");
			history.go(-1);
		</script>
		<%
		return;
	}  
	String sql = "";
	int count = 0;
	SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");

	Date end_time = sdf.parse(jzsj);
	Date date = new Date();
	if("1".equals(status)){
		 sql = "insert into APP_MYZJ_INFO  (title,content,status,dept_code,create_time,end_time,pub_time,website_code) values (?,?,?,?,to_date('"+kssj+"','YYYY-MM-DD'),to_date('"+jzsj+"','YYYY-MM-DD'),sysdate,?)";
		 count = executeUpdate(sql,new Object[]{title,content,status,dept_code,website_code});
	}else{    
		sql = "insert into APP_MYZJ_INFO  (title,content,status,dept_code,create_time,end_time,website_code) values (?,?,?,?,to_date('"+kssj+"','YYYY-MM-DD'),to_date('"+jzsj+"','YYYY-MM-DD'),?)";
		count = executeUpdate(sql,new Object[]{title,content,status,dept_code,website_code});
	}
	      
	if(count>0){     
		%>  
		<script type="text/javascript">
			alert("操作成功");
// 			window.location.href = "myzj_index_detail.jsp?guid="+myzj_id;
			window.location.href = "myzj_list.jsp?r=<%=new Date().getTime()%>";
			//window.opener=null;window.open('','_self');
			//window.close();
		</script>
		<%
		return;    
	}else{
		%>
		<script type="text/javascript">
			alert("操作失败");
			history.go(-1);
		</script>
		<%
		return;
	}
	
	
	
%>